# -*- coding: utf-8 -*-
# @Time     : 2023/12/8 2:13
# @Author   : JustFly
# @File     : fly.py
# @Software : PyCharm


import botpy
from botpy.types.message import Message
from botpy.message import DirectMessage
import re
from config.bot import APP_ID, CLIENT_SECRET
import channel_logic
import channel_private_logic


class MyClient(botpy.Client):
    async def on_at_message_create(self, message: Message):
        # 频道-聊天室
        reply_msg = channel_logic.func(message)
        # 回复消息
        await message.reply(content=reply_msg)

    async def on_direct_message_create(self, message: DirectMessage):
        # 频道-私信
        reply_msg = channel_private_logic.func(message)
        # 回复消息
        await message.reply(content=reply_msg)


# 订阅
intents = botpy.Intents.none()
intents.public_guild_messages = True
intents.direct_message = True
# 启动
client = MyClient(intents=intents)
client.run(appid=APP_ID, secret=CLIENT_SECRET)
